package com.suanfa;


/**
 * 将整数转换为二进制字符串
 *
 * @Author weijingchen
 * @Date 2025/5/27 21:06
 * @Version 1.0.0
 */
public class Test1 {
    public static void main(String[] args) {
        String s = toBinaryString(100);
        System.out.println(s);
    }

    private static String toBinaryString(int number) {
        StringBuilder stringBuilder = new StringBuilder();
        while (number != 0) {
            int remaindar = number % 2;
            number = number / 2;
            //insert 将remaindar  插入到stringBuilder的0索引位置
            stringBuilder.insert(0, remaindar);
        }

        return stringBuilder.toString();
    }
}
